package cc.avatar.model;

import java.util.Date;

public abstract class AccountingEvent {
    public abstract Party getStakeholder();
    public abstract Date getWhenOccurred();
    
    public abstract String getAtt1();
    public abstract String getAtt2();
    public abstract String getAtt3();
    //optional
    public String getAtt4(){
    	return "";
    }
    
	public AccountingEntry process(){
		return findRule().process(this);    
	}	
	
	//根据事件类型和发生时间获得相应的规则，其中的时间参数被送到有效时间段容器，
	//由它来查找得到对应时间的规则：
	private PostingRule findRule(){	
		PostingRule rule = getDefaultRule();
		return rule != null? rule : getStakeholder().getPostingRule(getWhenOccurred()) ;				
	}
	
	protected PostingRule getDefaultRule(){
		return null;
	}
}
